import axios from 'axios';
export function getDetail(data,id){
	console.log('id=',id);
	return dispatch=>{
		dispatch(fetchDetailData(data))
		axios.get(`https://cnodejs.org/api/v1/topic/${id}`)
		.then(res=>{
			console.log('result',res);
			dispatch(reciveListData(res.data.data));
		})
		.catch(error=>{
			console.log(error)
			dispatch(fetchDetailError());
		})
	}
	
}
function reciveListData(data){
	return {
		type: 'DETAIL_UPDATE_SUCC',
		data
	}
}
function fetchDetailData(data) {
	return {
		type: "DETAIL_UPDATE",
		loading: true,
		data: data
	}
}
function fetchDetailError() {
	return {
		type: "DETAIL_UPDATE_ERROR"
	}
}